<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 参考文档 -Request/Request.HTML</title>
</head>

<body>
  <div id="docs" class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Request-HTML">Request.HTML</a></h4>
      <h4 class="menu-item"><a href="#Element-Properties">Element.Properties</a></h4>
      <div class="menu-item"><a href="#Element-Properties:load">load</a></div>
      <h4 class="menu-item"><a href="#Element">Element</a></h4>
      <div class="menu-item"><a href="#Element:load">load</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Request-HTML"><a href="#Request-HTML">Class: Request.HTML</a></h1>
      <p class="description">Request Specifically made for receiving HTML.</p>
      <h3>Extends:</h3>
      <p><a href="../../../docs/core/Request/Request.html">Request</a></p>
      <h3>语法: </h3>
      <pre class="javascript"><span class="kw2">var</span> myHTMLRequest = <span class="kw2">new</span> Request.<span class="me1">HTML</span><span class="br0">(</span><span class="br0">[</span>options<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>参数: </h3>
      <ol>
        <li>options - (<em>object</em>, 可选) See options below.  Also inherited are all the options from <a href="../../../docs/core/Request/Request.html">Request</a>.</li>
      </ol>
      <h3>Options:</h3>
      <ul>
        <li>evalScripts  - (<em>boolean</em>: defaults to true) If set to true, <code>script</code> tags inside the response will be evaluated. This overrides the <code>false</code> default from Request.</li>
        <li>update - (<em>element</em>: defaults to null) The Element to insert the response text of the Request into upon completion of the request.</li>
        <li>append - (<em>element</em>: defaults to null) The Element to append the response text of the Request into upon completion of the request.</li>
        <li>filter - (<em>mixed</em>: defaults to null) To filter the response tree by a selector or function. See <a href="../../../docs/core/Element/Element.html#Elements:filter">Elements:filter</a> </li>
      </ul>
      <h3>Events:</h3>
      <h4>success</h4>
      <ul>
        <li>(<em>function</em>) Function to execute when the HTML request completes. This overrides the signature of the Request success event.</li>
      </ul>
      <h5>Signature:</h5>
      <pre class="javascript">onSuccess<span class="br0">(</span>responseTree, responseElements, responseHTML, responseJavaScript<span class="br0">)</span>
</pre>
      <h5>参数: </h5>
      <ol>
        <li>responseTree       - (<em>element</em>) The node list of the remote response.</li>
        <li>responseElements   - (<em>array</em>)   An array containing all elements of the remote response.</li>
        <li>responseHTML       - (<em>string</em>)  The content of the remote response.</li>
        <li>responseJavaScript - (<em>string</em>)  The portion of JavaScript from the remote response.</li>
      </ol>
      <h3>返回值: </h3>
      <ul>
        <li>(<em>object</em>) A new Request.HTML instance.</li>
      </ul>
      <h3>示例: </h3>
      <h4>Simple GET Request:</h4>
      <pre class="javascript"><span class="kw2">var</span> myHTMLRequest = <span class="kw2">new</span> Request.<span class="me1">HTML</span><span class="br0">(</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="st0">'myPage.html'</span><span class="br0">)</span>;

</pre>
      <h4>POST Request with data as String:</h4>
      <pre class="javascript"><span class="kw2">var</span> myHTMLRequest = <span class="kw2">new</span> Request.<span class="me1">HTML</span><span class="br0">(</span><span class="br0">{</span>url:<span class="st0">'myPage.html'</span><span class="br0">}</span><span class="br0">)</span>.<span class="me1">post</span><span class="br0">(</span><span class="st0">'user_id=25&amp;save=true'</span><span class="br0">)</span>;

</pre>
      <h4>Data from Object Passed via GET:</h4>
      <pre class="javascript"><span class="co1">//Loads "load/?user_id=25".</span>
<span class="kw2">var</span> myHTMLRequest = <span class="kw2">new</span> Request.<span class="me1">HTML</span><span class="br0">(</span><span class="br0">{</span>url:<span class="st0">'load/'</span><span class="br0">}</span><span class="br0">)</span>.<span class="me1">get</span><span class="br0">(</span><span class="br0">{</span><span class="st0">'user_id'</span>: <span class="nu0">25</span><span class="br0">}</span><span class="br0">)</span>;

</pre>
      <h4>Data from Element via POST:</h4>
      <h5>HTML</h5>
      <pre class="javascript">&lt;form action=<span class="st0">"save/"</span> method=<span class="st0">"post"</span> id=<span class="st0">"user-form"</span>&gt;

    &lt;p&gt;
        Search: &lt;input type=<span class="st0">"text"</span> <span class="kw3">name</span>=<span class="st0">"search"</span> /&gt;
        Search <span class="kw1">in</span> description: &lt;input type=<span class="st0">"checkbox"</span> <span class="kw3">name</span>=<span class="st0">"search_description"</span> value=<span class="st0">"yes"</span> /&gt;

        &lt;input type=<span class="st0">"submit"</span> /&gt;
    &lt;/p&gt;
&lt;/form&gt;
</pre>
      <h5>JavaScript</h5>
      <pre class="javascript"><span class="co1">//Needs to be in a submit event or the form handler.</span>

<span class="kw2">var</span> myHTMLRequest = <span class="kw2">new</span> Request.<span class="me1">HTML</span><span class="br0">(</span><span class="br0">{</span>url:<span class="st0">'save/'</span><span class="br0">}</span><span class="br0">)</span>.<span class="me1">post</span><span class="br0">(</span>$<span class="br0">(</span><span class="st0">'user-form'</span><span class="br0">)</span><span class="br0">)</span>;

</pre>
      <h3>另参考:</h3>
      <p><a href="../../../docs/core/Request/Request.html">Request</a></p>
      <h1 id="Element-Properties"><a href="#Element-Properties">Object: Element.Properties</a></h1>
      <p class="description">see <a href="../../../docs/core/Element/Element.html#Element-Properties">Element.Properties</a></p>
      <h2 id="Element-Properties:load"><a href="#Element-Properties:load">Element Property: load</a></h2>
      <h3 class="description">Setter</h3>
      <p>Sets a default Request.HTML instance for an Element.</p>
      <h4>语法: </h4>
      <pre class="javascript">el.<span class="me1">set</span><span class="br0">(</span><span class="st0">'load'</span><span class="br0">[</span>, options<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h4>参数: </h4>
      <ol>
        <li>options - (<em>object</em>) The Request options.</li>
      </ol>
      <h4>返回值: </h4>
      <ul>
        <li>(<em>element</em>) The target Element.</li>
      </ul>
      <h4>示例: </h4>
      <pre class="javascript">el.<span class="me1">set</span><span class="br0">(</span><span class="st0">'load'</span>, <span class="br0">{</span>evalScripts: <span class="kw2">true</span><span class="br0">}</span><span class="br0">)</span>;
el.<span class="me1">load</span><span class="br0">(</span><span class="st0">'some/request/uri'</span><span class="br0">)</span>;

</pre>
      <h3>Getter</h3>
      <p>Returns either the previously set Request.HTML instance or a new one with default options.</p>
      <h4>语法: </h4>
      <pre class="javascript">el.<span class="me1">get</span><span class="br0">(</span><span class="st0">'load'</span><span class="br0">)</span>;

</pre>
      <h4>参数: </h4>
      <ol>
        <li>property - (<em>string</em>) the Request.HTML property argument.</li>
      </ol>
      <h4>返回值: </h4>
      <ul>
        <li>(<em>object</em>) The Request instance.</li>
      </ul>
      <h4>示例: </h4>
      <pre class="javascript">el.<span class="me1">set</span><span class="br0">(</span><span class="st0">'load'</span>, <span class="br0">{</span>method: <span class="st0">'get'</span><span class="br0">}</span><span class="br0">)</span>;
el.<span class="me1">load</span><span class="br0">(</span><span class="st0">'test.html'</span><span class="br0">)</span>;

<span class="co1">// the getter returns the Request.HTML instance, making its class methods available.</span>
el.<span class="me1">get</span><span class="br0">(</span><span class="st0">'load'</span><span class="br0">)</span>.<span class="me1">post</span><span class="br0">(</span><span class="st0">'http://localhost/script'</span><span class="br0">)</span>;
</pre>
      <h1 id="Element"><a href="#Element">类型: Element</a></h1>
      <p class="description">Custom Type to allow all of its methods to be used with any DOM element via the dollar function <a href="../../../docs/core/Element/Element.html#Window:dollar">$</a>.</p>
      <h2 id="Element:load"><a href="#Element:load">Element Method: load</a></h2>
      <p class="description">Updates the content of the Element with a Request.HTML GET request.</p>
      <h3>语法: </h3>
      <pre class="javascript">myElement.<span class="me1">load</span><span class="br0">(</span>url<span class="br0">)</span>;

</pre>
      <h3>参数: </h3>
      <ol>
        <li>url - (<em>string</em>) The URL pointing to the server-side document.</li>
      </ol>
      <h3>返回值: </h3>
      <ul>
        <li>(<em>element</em>) The target Element.</li>
      </ul>
      <h3>示例: </h3>
      <h5>HTML</h5>
      <pre class="javascript">&lt;div id=<span class="st0">"content"</span>&gt;Loading content...&lt;/div&gt;
</pre>
      <h5>JavaScript</h5>
      <pre class="javascript">$<span class="br0">(</span><span class="st0">'content'</span><span class="br0">)</span>.<span class="me1">load</span><span class="br0">(</span><span class="st0">'page_1.html'</span><span class="br0">)</span>;
</pre>
      <h3>另参考:</h3>
      <ul>
        <li> <a href="../../../docs/core/Element/Element.html#Window:dollar">$</a>, <a href="../../../docs/core/Request/Request.html">Request</a> </li>
      </ul>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
